import pyautogui
import time
import pygetwindow as gw
# 通达信软件的窗口标题
window_title = "大智慧"
# 查找通达信软件的窗口并将其激活
try:
    window = pyautogui.getWindowsWithTitle(window_title)[0]
    window.activate()
except IndexError:
    print(f"无法找到标题为 '{window_title}' 的窗口")
    exit()
# 等待几秒钟确保窗口已经激活
time.sleep(2)
# 输入股票代码
pyautogui.write('600600', interval=0.25)
# 按下回车键
pyautogui.press('enter')